t = {}
-- do not use the negative number as operation position

-- insert
print("insert: ")
-- not specify the insert position
for i = 1, 10 do
	table.insert(t, i)
end
-- specify the insert position
table.insert(t, 2, -100) 	-- 2 is the position

print("count: " .. #t) 	-- the count of element
for key, value in ipairs(t) do
	print(key, value)
end

-- remove (return the removed element)
print("remove: ")
-- not specify the remove position (remove the last element)
table.remove(t)
-- specify the remove position
table.remove(t, 1)

print("count: " .. #t) 	-- the count of element
for key, value in ipairs(t) do
	print(key, value)
end

-- move
print("move: ")
-- table.move(a, f, e, t) -> copy the [f,e] elements in table a to position t
table.move(t, 2, 4, 1)
for key, value in ipairs(t) do
	print(key, value)
end
-- table.move(a, f, e, t, b)	-> copy the [f,e] elements in table a to position t in table b
print("move(clone): ")
clone_t = {}
table.move(t, 1, #t, 1, clone_t)
for key, value in ipairs(clone_t) do
	print(key, value)
end

-- pack
print("pack: ")
-- table.pack(...) 	variable args ---> table
t = table.pack(1, 2, 43, 5, 6, 7)
for _, value in ipairs(t) do
	print(value)
end

-- unpack
print("unpack: ")
-- table.unpack(t, a, b) 	table ---> variable args, [a,b] indicate the range
print(table.unpack(t))
print(table.unpack(t, 2, 3))

-- sort
print("sort: ")
t = {12, 1, 5, 67, 99}
table.sort(t)
for _, val in ipairs(t) do
	print(val)
end
